package cn.hh.wechatkit.data.postdata.card.meet;

import cn.hh.wechatkit.data.postdata.card.Meta_ICard;
import cn.hh.wechatkit.pojo.card.enums.Wx_CardTypeEnum;
import cn.hh.wechatkit.pojo.card.enums.Wx_CodeTypeEnum;
import lombok.*;

import java.util.Date;
import java.util.List;

@Data
public class Meta_MeetCard implements Meta_ICard {

    String card_type = Wx_CardTypeEnum.MEETING_TICKET.name();  //会议票
    Meta_MeetCard_Ticket meeting_ticket = new Meta_MeetCard_Ticket();

    /**
     * Created this one by HMH on 2017/7/4.
     */
    @Data
    public class Meta_MeetCard_Ticket{

        Meta_MeetCard_Ticket_BaseInfo base_info = new Meta_MeetCard_Ticket_BaseInfo();
        String meeting_detail;

        @Data
        public class Meta_MeetCard_Ticket_BaseInfo{

            String logo_url;
            String brand_name;
            String code_type = Wx_CodeTypeEnum.CODE_TYPE_QRCODE.name();
            String title;
            String color = "Color010";  //默认微信绿
            String notice;
            String service_phone;
            String description;
            Integer get_limit = 1;    //默认只能有一张
            Boolean use_custom_code = false;    //默认不使用自定义的code
            Boolean bind_openid = false;    //默认不绑定OpenId
            Boolean can_share = true;  //默认允许分享
            Boolean can_give_friend = false;    //默认不能转让
            String custom_url_name = "查看更多";
            String custom_url;
            String custom_url_sub_title = "";
            List<Long> location_id_list = null; //默认不限定位置
            Meta_Sku sku = new Meta_Sku();
            Meta_DateInfo date_info = new Meta_DateInfo();

            @Data
            public class Meta_DateInfo {
                Integer type=1; //默认使用绝对日期
                Long begin_timestamp;
                Long end_timestamp;
            }

            @Data
            public class Meta_Sku {
                Integer quantity = 50;   //默认50张
            }
        }

    }

    @Override
    public String getLogoUrl() {
        return this.meeting_ticket.base_info.logo_url;
    }

    @Override
    public String getBrandName() {
        return this.meeting_ticket.base_info.brand_name;
    }

    @Override
    public String getCardType() {
        return card_type;
    }

    @Override
    public String getCodeType() {
        return this.meeting_ticket.base_info.code_type;
    }

    @Override
    public String getTitle() {
        return this.meeting_ticket.base_info.title;
    }

    @Override
    public String getNotice() {
        return this.meeting_ticket.base_info.notice;
    }

    @Override
    public String getServicePhone() {
        return this.meeting_ticket.base_info.service_phone;
    }

    @Override
    public String getDescription() {
        return this.meeting_ticket.base_info.description;
    }

    @Override
    public Long getBeginTimeStamp() {
        return this.meeting_ticket.base_info.date_info.begin_timestamp/1000;
    }

    @Override
    public Date getBeginDate() {
        return new Date(meeting_ticket.base_info.date_info.begin_timestamp);
    }

    @Override
    public Long getEndTimeStamp() {
        return this.meeting_ticket.base_info.date_info.end_timestamp/1000;
    }

    @Override
    public Date getEndDate(){
        return new Date(meeting_ticket.base_info.date_info.end_timestamp);

    }

    @Override
    public Integer getQuantity() {
        return this.meeting_ticket.base_info.sku.quantity;
    }

    @Override
    public Integer getLimit() {
        return this.meeting_ticket.base_info.get_limit;
    }

    @Override
    public Boolean getCanShare() {
        return this.meeting_ticket.base_info.can_share;
    }

    @Override
    public Boolean getCanGiveFriend() {
        return this.meeting_ticket.base_info.can_give_friend;
    }

    @Override
    public String getCustomUrl() {
        return this.meeting_ticket.base_info.custom_url;
    }

    @Override
    public String getCustomUrlName() {
        return this.meeting_ticket.base_info.custom_url_name;
    }

    @Override
    public String getCustomUrlSubTitle() {
        return this.meeting_ticket.base_info.custom_url_sub_title;
    }

    @Override
    public String getMeetingDetail() {
        return this.meeting_ticket.meeting_detail;
    }


    @Override
    public Meta_MeetCard setLogoUrl(String url) {
        this.meeting_ticket.base_info.logo_url = url;
        return this;
    }

    @Override
    public Meta_MeetCard setBrandName(String brandName) {
        this.meeting_ticket.base_info.brand_name = brandName;
        return this;
    }

    @Override
    public Meta_MeetCard setCodeType(Wx_CodeTypeEnum type) {
        this.meeting_ticket.base_info.code_type = type.name();
        return this;
    }

    @Override
    public Meta_MeetCard setTitle(String title) {
        this.meeting_ticket.base_info.title = title;
        return this;
    }

    @Override
    public Meta_MeetCard setNotice(String notice) {
        this.meeting_ticket.base_info.notice = notice;
        return this;
    }

    @Override
    public Meta_MeetCard setServicePhone(String phone) {
        this.meeting_ticket.base_info.service_phone = phone;
        return this;
    }

    @Override
    public Meta_MeetCard setDescription(String description) {
        this.meeting_ticket.base_info.description = description;
        return this;
    }

    @Override
    public Meta_MeetCard setBeginTimeStamp(Date timestamp) {
        this.meeting_ticket.base_info.date_info.begin_timestamp = timestamp.getTime();
        return this;
    }

    @Override
    public Meta_MeetCard setEndTimeStamp(Date timestamp) {
        this.meeting_ticket.base_info.date_info.end_timestamp = timestamp.getTime();
        return this;
    }

    @Override
    public Meta_MeetCard setQuantity(Integer quantity) {
        this.meeting_ticket.base_info.sku.quantity = quantity;
        return this;
    }

    @Override
    public Meta_MeetCard setLimit(Integer limit) {
        this.meeting_ticket.base_info.get_limit = limit;
        return this;
    }

    @Override
    public Meta_MeetCard setCanShare(boolean canShare) {
        this.meeting_ticket.base_info.can_share = canShare;
        return this;
    }

    @Override
    public Meta_MeetCard setCanGiveFriend(boolean canGiveFriend) {
        this.meeting_ticket.base_info.can_give_friend = canGiveFriend;
        return this;
    }

    @Override
    public Meta_MeetCard setCustomUrl(String url) {
        this.meeting_ticket.base_info.custom_url = url;
        return this;
    }

    @Override
    public Meta_MeetCard setColor(String color) {
        //will do nothing
        return this;
    }

    @Override
    public Meta_MeetCard setCustomUrlName(String urlName) {
        this.meeting_ticket.base_info.custom_url_name = urlName;
        return this;
    }

    @Override
    public Meta_MeetCard setCustomUrlSubTitle(String title) {
        this.meeting_ticket.base_info.custom_url_sub_title = title;
        return this;
    }

    @Override
    public Meta_MeetCard setMeetingDetail(String meetingDetail) {
        this.meeting_ticket.meeting_detail = meetingDetail;
        return this;
    }


}
